Repository navigation
fix(sleep): don't write the same learned item twice on replace - #442
Open
Lanre Shittu (Shizoqua) wants to merge 1 commit into
Open
Lanre Shittu (Shizoqua) wants to merge 1 commit into
Lanre Shittu (Shizoqua) wants to merge 1 commit into
Conversation
apply_edits_detailed skips an add whose item is already in the learned block, but replace wrote its replacement once per line the anchor matched and never checked the other lines. A replacement equal to an existing item, or an anchor that matched several items, left duplicate bullets in the block. Place the replacement once, at the first matching line, and drop it when an unmatched line already holds it. A replace that changes nothing is still reported as unmatched.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
apply_edits_detailedinskillopt_sleep/memory.pyskips anaddwhose item is already in the learned block, butreplacewrote its replacement once for every line the anchor matched and never checked the other lines. A replacement equal to an existing item, or an anchor that matched several items, left duplicate bullets in the block.Changes
replacenow writes the replacement once, at the first matching line. Later matching lines are dropped, and so is the matching line itself when an unmatched line already holds the replacement.unmatched. Duplicates that were already in an older block are left alone.CHANGELOG.md: entry under Fixed.Tests
New
tests/test_learned_replace_dedup.py:The first two fail on main and pass with the fix.
tests/test_learned_block_roundtrip.pypasses unchanged. Full suite: 2397 passed, 12 skipped, 4 xfailed.ruff checkpasses on the changed files.Fixes #441